/**
 * 飞机表单
 */
<template>
    <el-form v-loading="loading" :model="formData" :rules="currentFormRules" ref="formRef" label-width="130px" :scroll-to-error="true">
        <vp-card>
            <template #header>
                <vp-label zh="基本信息" en="Basic Info" />
            </template>
            <el-row>
                <vp-col :span="4">
                    <el-form-item prop="jxid">
                        <template #label><vp-label zh="机型" en="A/C Type"/></template>
                        <VpAircraftTypeSelect 
                            v-if="isEditPage"
                            :selectedId="formData.jx" 
                            :fjjx="true"
                            :disabled="type !== 'add'"
                            class="w100"
                            auth
                            @selected="(obj:any) =>{formData.jx = obj.jx; formData.jxid = obj.id;}"
                        />
                        <vp-text v-else>{{ formData.jx }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="fjzch">
                        <template #label><vp-label zh="飞机号" en="A/C REG" /></template>
                        <el-input v-model="formData.fjzch" v-if="isEditPage" v-trim maxlength="50">
                        </el-input>
                        <vp-text v-else>{{ formData.fjzch }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="fjxlh">
                        <template #label><vp-label zh="序列号" en="MSN" /></template>
                        <el-input v-model="formData.fjxlh" :disabled="type !== 'add'" v-if="isEditPage" v-trim maxlength="50">
                        </el-input>
                        <vp-text v-else>{{ formData.fjxlh }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="bzm">
                        <template #label><vp-label zh="备注说明" en="Note Name" /></template>
                        <el-input v-model="formData.bzm" v-if="isEditPage" v-trim maxlength="100">
                        </el-input>
                        <vp-text v-else>{{ formData.bzm }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="gsbs">
                        <template #label><vp-label zh="归属" en="Ownership"/></template>
                        <el-radio-group v-model="formData.gsbs" v-if="isEditPage">
                            <el-radio :value="10">本单位</el-radio>
                            <el-radio :value="20">托管</el-radio>
                        </el-radio-group>
                        <vp-text v-else>{{ formData.gsbs === 10 ? '本单位' : formData.gsbs === 20 ? '托管' : '' }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4" v-if="formData.gsbs === 20">
                    <el-form-item prop="ssdwid">
                        <template #label><vp-label zh="客户名称" en="Customer Name"/></template>
                        <el-input v-model="formData.ssdwmc" readonly v-if="isEditPage">
                            <template #append>
                                <el-button @click="handleChooseCustomer"><SvgIcon name="ele-Search" /></el-button>
                            </template>
                        </el-input>
                        <vp-text v-else>{{ formData.ssdwmc }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="jdid">
                        <template #label><vp-label zh="基地" en="Base"/></template>
                        <VpBaseSelectTree 
                            v-if="isEditPage"
                            :selectedId="formData.jdid" 
                            @treeSelected="(obj:any) =>{formData.jdid = obj.id;}"
                            class="w100"
                        />
                        <vp-text v-else>{{ formData.jdmc }}</vp-text>
                    </el-form-item>
                </vp-col>
            </el-row>
            <el-row>
                <vp-col :span="4">
                    <el-form-item prop="scrq">
                    <template #label><vp-label zh="生产日期" en="MFD"/></template>
                        <el-date-picker
                            v-if="isEditPage"
                            v-model="formData.scrq"
                            value-format="YYYY-MM-DD"
                            type="date"
                            class="w100"
                        />
                        <vp-text v-else>{{ formData.scrq }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="ccrq">
                    <template #label><vp-label zh="制造厂出厂日期" en="DOM"/></template>
                        <el-date-picker
                            v-if="isEditPage"
                            v-model="formData.ccrq"
                            value-format="YYYY-MM-DD"
                            type="date"
                            class="w100"
                        />
                        <vp-text v-else>{{ formData.ccrq }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="sctryxrq">
                    <template #label><vp-label zh="首次投入运行日期" en="Service Date"/></template>
                        <el-date-picker
                            v-if="isEditPage"
                            v-model="formData.sctryxrq"
                            value-format="YYYY-MM-DD"
                            type="date"
                            class="w100"
                        />
                        <vp-text v-else>{{ formData.sctryxrq }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="smsm">
                        <template #label><vp-label zh="S模式码" en="S Mode Code" /></template>
                        <el-input v-model="formData.smsm" v-if="isEditPage" v-trim maxlength="100">
                        </el-input>
                        <span v-else>{{ formData.smsm }}</span>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="xhh">
                        <template #label><vp-label zh="选呼号" en="Select Call Code" /></template>
                        <el-input v-model="formData.xhh" v-if="isEditPage" v-trim maxlength="100">
                        </el-input>
                        <vp-text v-else>{{ formData.xhh }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="yxgf">
                        <template #label><vp-label zh="运行规范" en="Specification" /></template>
                        <el-input v-model="formData.yxgf" v-if="isEditPage" v-trim maxlength="100">
                        </el-input>
                        <span v-else>{{ formData.yxgf }}</span>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="kz">
                        <template #label><vp-label zh="空重" en="Empty Weight" /></template>
                        <el-input 
                            v-model="formData.kz" 
                            v-if="isEditPage" 
                            @input="(val:string) => {formData.kz = verifyNumberIntegerAndFloat3(val) }" 
                            v-trim
                            maxlength="13"
                        >
                            <template #append>
                                <VpDictSelect 
                                    :lxid="401" 
                                    :selectedId="formData.zldw"
                                    v-if="isEditPage"
                                    @dictSelected="dicts => { formData.zldw = dicts }" 
                                    style="width: 90px;"
                                />
                            </template>
                        </el-input>
                        <vp-text v-else>{{ formData.kz || formData.kz === 0 ? formData.kz + formData.zldw : '' }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="zdqfzl">
                        <template #label><vp-label zh="最大起飞重量" en="Max Takeoff Weight" /></template>
                        <el-input 
                            v-model="formData.zdqfzl" 
                            v-if="isEditPage" 
                            @input="(val:string) => {formData.zdqfzl = verifyNumberIntegerAndFloat3(val) }" 
                            v-trim
                            maxlength="13"
                        >
                            <template #append>
                                <VpDictSelect 
                                    :lxid="401" 
                                    :selectedId="formData.zldw"
                                    v-if="isEditPage"
                                    @dictSelected="dicts => { formData.zldw = dicts }" 
                                    style="width: 90px;"
                                />
                            </template>
                        </el-input>
                        <vp-text v-else>{{ formData.zdqfzl || formData.zdqfzl === 0 ? formData.kz + formData.zldw : '' }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="zdzlzl">
                        <template #label><vp-label zh="最大着陆重量" en="Max Landing Weight" /></template>
                        <el-input 
                            v-model="formData.zdzlzl" 
                            v-if="isEditPage" 
                            @input="(val:string) => {formData.zdzlzl = verifyNumberIntegerAndFloat3(val) }" 
                            v-trim
                            maxlength="13"
                        >
                            <template #append>
                                <VpDictSelect 
                                    :lxid="401" 
                                    :selectedId="formData.zldw"
                                    v-if="isEditPage"
                                    @dictSelected="dicts => { formData.zldw = dicts }" 
                                    style="width: 90px;"
                                />
                            </template>
                        </el-input>
                        <vp-text v-else>{{ formData.zdzlzl || formData.zdzlzl === 0 ? formData.kz + formData.zldw : '' }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="yxrn">
                        <template #label><vp-label zh="油箱容量" en="FTC" /></template>
                        <el-input 
                            v-model="formData.yxrn" 
                            v-if="isEditPage" 
                            @input="(val:string) => {formData.yxrn = verifyNumberIntegerAndFloat3(val) }" 
                            v-trim
                            maxlength="13"
                        >
                            <template #append>
                                <VpDictSelect 
                                    :lxid="401" 
                                    :selectedId="formData.yxrndw"
                                    v-if="isEditPage"
                                    @dictSelected="dicts => { formData.yxrndw = dicts }" 
                                    style="width: 90px;"
                                />
                            </template>
                        </el-input>
                        <vp-text v-else>{{ formData.yxrn || formData.yxrn === 0 ? formData.kz + formData.yxrndw : '' }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="ryxh">
                        <template #label><vp-label zh="燃油型号" en="Fuel Grade" /></template>
                        <el-input v-model="formData.ryxh" v-if="isEditPage" v-trim maxlength="100">
                        </el-input>
                        <vp-text v-else>{{ formData.ryxh }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="fdjhybh">
                        <template #label><vp-label zh="发动机滑油牌号" en="Engine Oil Grade" /></template>
                        <el-input v-model="formData.fdjhybh" v-if="isEditPage" v-trim maxlength="100">
                        </el-input>
                        <vp-text v-else>{{ formData.fdjhybh }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="zwsl">
                        <template #label><vp-label zh="座位数" en="Seat Count" /></template>
                        <el-input 
                            v-model="formData.zwsl" 
                            v-if="isEditPage" 
                            @input="(val:string) => {formData.zwsl = verifiyNumberInteger(val) }" 
                            v-trim
                            maxlength="5"
                        >
                        </el-input>
                        <vp-text v-else>{{ formData.zwsl }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="wxtxxt">
                        <template #label><vp-label zh="卫星通讯系统" en="AMSS" /></template>
                        <el-input v-model="formData.wxtxxt" v-if="isEditPage" v-trim maxlength="100">
                        </el-input>
                        <vp-text v-else>{{ formData.wxtxxt }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="dzxt">
                        <template #label><vp-label zh="电子系统" en="Avionics System" /></template>
                        <el-input v-model="formData.dzxt" v-if="isEditPage" v-trim maxlength="100">
                        </el-input>
                        <vp-text v-else>{{ formData.dzxt }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="adsbzt">
                        <template #label><vp-label zh="ADS-B状态" en="ADS-B State" /></template>
                        <el-input v-model="formData.adsbzt" v-if="isEditPage" v-trim maxlength="100">
                        </el-input>
                        <vp-text v-else>{{ formData.adsbzt }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="adsbjsbz">
                        <template #label><vp-label zh="ADS-B技术标准" en="ADS-B Standard" /></template>
                        <el-input v-model="formData.adsbjsbz" v-if="isEditPage" v-trim maxlength="100">
                        </el-input>
                        <vp-text v-else>{{ formData.adsbjsbz }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="1">
                    <el-form-item prop="bz">
                        <template #label><vp-label zh="备注" en="Remark"/></template>
                        <el-input 
                            type="textarea" 
                            v-model="formData.bz" 
                            maxlength="1000" 
                            :autosize="{ minRows: 2}"
                            v-if="isEditPage"
                        >
                        </el-input>
                        <vp-text v-else >{{ formData.bz }}</vp-text>
                    </el-form-item>
                </vp-col>
            </el-row>
        </vp-card>
        <vp-card>
            <template #header>
                <vp-label zh="电子设备信息" en="Avionics Equipment Info" />
            </template>
            <el-row>
                <vp-col :span="1">
                    <el-form-item>
                        <template #label><vp-label zh="机上系统软件" en="System Software" /></template>
                        <vp-table :data="formData.softwareConfigs" max-height="400">
                            <el-table-column type="index" align="center" label="#"></el-table-column>
                            <el-table-column min-width="200" show-overflow-tooltip>
                                <template #header><vp-label zh="名称" en="Name"/></template>
                                <template #default="scope">
                                    <el-form-item :prop="`softwareConfigs[${scope.$index}].mc`" :rules="formRules.softwareConfigs.mc">
                                        <el-input v-model="scope.row.mc" maxlength="100" v-if="isEditPage">
                                        </el-input>
                                        <span v-else>{{ scope.row.mc }}</span>
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column width="160" show-overflow-tooltip>
                                <template #header><vp-label zh="件号" en="P/N"/></template>
                                <template #default="scope">
                                    <el-input v-model="scope.row.jh" maxlength="100" v-if="isEditPage" />
                                    <span v-else>{{ scope.row.jh }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column width="160" show-overflow-tooltip>
                                <template #header><vp-label zh="版本" en="Revision"/></template>
                                <template #default="scope">
                                    <el-input v-model="scope.row.bb" maxlength="100" v-if="isEditPage" />
                                    <span v-else>{{ scope.row.bb }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column width="160" show-overflow-tooltip>
                                <template #header><vp-label zh="日期" en="Date"/></template>
                                <template #default="scope">
                                    <el-date-picker
                                        v-model="scope.row.rq"
                                        v-if="isEditPage"
                                        value-format="YYYY-MM-DD"
                                        type="date"
                                        class="w100"
                                    />
                                    <span v-else>{{ scope.row.rq }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column width="250" show-overflow-tooltip>
                                <template #header><vp-label zh="附件" en="Attachment"/></template>
                                <template #default="scope">
                                    <RowAttachment 
                                        :attachmentList="scope.row.attachments" 
                                        :readOnly="!isEditPage"
                                        @attachmentListEmit="scope.row.attachments = $event"
                                    />
                                </template>
                            </el-table-column>
                            <el-table-column align="center" width="60" v-if="isEditPage">
                                <template #header>
                                    <el-space>
                                        <el-button circle @click="handleAddSoftwareConfig()"><SvgIcon name="ele-Plus"></SvgIcon></el-button>
                                    </el-space>
                                </template>
                                <template #default="scope">
                                    <el-button circle @click="handleDeleteSoftwareConfig(scope.$index)"><SvgIcon name="ele-Minus"></SvgIcon></el-button>
                                </template>
                            </el-table-column>
                        </vp-table>
                    </el-form-item>
                </vp-col>
                <vp-col :span="1">
                    <el-form-item prop="dzsbxxAttachments">
                        <template #label><vp-label zh="电子设备信息附件" en="Avionics Equip. Info." /></template>
                        <RowAttachment 
                            :attachmentList="formData.dzsbxxAttachments" 
                            :readOnly="!isEditPage"
                            @attachmentListEmit="formData.dzsbxxAttachments = $event"
                        />
                    </el-form-item>
                </vp-col>
                <vp-col :span="1">
                    <el-form-item prop="dzsbxxAttachments">
                        <template #label><vp-label zh="电子设备软件构型清单附件" en="Avionics Equip. Sw. Config. List" /></template>
                        <RowAttachment 
                            :attachmentList="formData.dzsbrjgxqdAttachments" 
                            :readOnly="!isEditPage"
                            @attachmentListEmit="formData.dzsbrjgxqdAttachments = $event"
                        />
                    </el-form-item>
                </vp-col>
            </el-row>
        </vp-card>
        <vp-card>
            <template #header>
                <vp-label zh="飞机证件信息" en="Aircraft Certificates Info" />
            </template>
            <el-row>
                <vp-col :span="4">
                    <el-form-item prop="certificates[0].zjh" :rules="currentFormRule(formRules.certificates.zjh)">
                        <template #label><vp-label zh="国籍登记证号" en="Natl. Reg. Cert. No." /></template>
                        <el-input v-model="formData.certificates[0].zjh" v-if="isEditPage" v-trim maxlength="100">
                        </el-input>
                        <vp-text v-else>{{ formData.certificates[0].zjh }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="certificates[0].bfrq" :rules="currentFormRule(formRules.certificates.bfrq)">
                    <template #label><vp-label zh="颁发日期" en="Issue Date"/></template>
                        <el-date-picker
                            v-if="isEditPage"
                            v-model="formData.certificates[0].bfrq"
                            value-format="YYYY-MM-DD"
                            type="date"
                            class="w100"
                        />
                        <vp-text v-else>{{ formData.certificates[0].bfrq }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="certificates[0].yxq" :rules="currentFormRule(formRules.certificates.yxq0)">
                    <template #label><vp-label zh="有效期" en="Valid Period"/></template>
                        <el-date-picker
                            v-if="isEditPage"
                            v-model="formData.certificates[0].yxq"
                            value-format="YYYY-MM-DD"
                            type="date"
                            class="w100"
                        />
                        <vp-text v-else>{{ formData.certificates[0].yxq }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4" v-if="isEditPage">
                    <el-form-item>
                        <template #label><vp-label zh="附件" en="Attachment" /></template>
                        <RowAttachment 
                            :attachmentList="formData.certificates[0].attachments" 
                            :readOnly="!isEditPage"
                            :show-attachment="false"
                            accept=".pdf"
                            @attachmentListEmit="formData.certificates[0].attachments = $event"
                        />
                    </el-form-item>
                </vp-col>
            </el-row>
            <el-row>
                <vp-col :span="4">
                    <el-form-item prop="certificates[1].zjh" :rules="currentFormRule(formRules.certificates.zjh)">
                        <template #label><vp-label zh="适航证号" en="Airworth. Cert. No." /></template>
                        <el-input v-model="formData.certificates[1].zjh" v-if="isEditPage" v-trim maxlength="100">
                        </el-input>
                        <vp-text v-else>{{ formData.certificates[1].zjh }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="certificates[1].bfrq" :rules="currentFormRule(formRules.certificates.bfrq)">
                    <template #label><vp-label zh="颁发日期" en="Issue Date"/></template>
                        <el-date-picker
                            v-if="isEditPage"
                            v-model="formData.certificates[1].bfrq"
                            value-format="YYYY-MM-DD"
                            type="date"
                            class="w100"
                        />
                        <vp-text v-else>{{ formData.certificates[1].bfrq }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="certificates[1].yxq" :rules="currentFormRule(formRules.certificates.yxq1)">
                    <template #label><vp-label zh="年检有效期" en="Inspect Valid Period"/></template>
                        <el-date-picker
                            v-if="isEditPage"
                            v-model="formData.certificates[1].yxq"
                            value-format="YYYY-MM-DD"
                            type="date"
                            class="w100"
                        />
                        <vp-text v-else>{{ formData.certificates[1].yxq }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4" v-if="isEditPage">
                    <el-form-item>
                        <template #label><vp-label zh="附件" en="Attachment" /></template>
                        <RowAttachment 
                            :attachmentList="formData.certificates[1].attachments" 
                            :readOnly="!isEditPage"
                            :show-attachment="false"
                            accept=".pdf"
                            @attachmentListEmit="formData.certificates[1].attachments = $event"
                        />
                    </el-form-item>
                </vp-col>
            </el-row>
            <el-row>
                <vp-col :span="4">
                    <el-form-item prop="certificates[2].zjh" :rules="currentFormRule(formRules.certificates.zjh)">
                        <template #label><vp-label zh="无线电台执照号" en="Radio Stn. Lic. No." /></template>
                        <el-input v-model="formData.certificates[2].zjh" v-if="isEditPage" v-trim maxlength="100">
                        </el-input>
                        <vp-text v-else>{{ formData.certificates[2].zjh }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="certificates[2].bfrq" :rules="currentFormRule(formRules.certificates.bfrq)">
                    <template #label><vp-label zh="颁发日期" en="Issue Date"/></template>
                        <el-date-picker
                            v-if="isEditPage"
                            v-model="formData.certificates[2].bfrq"
                            value-format="YYYY-MM-DD"
                            type="date"
                            class="w100"
                        />
                        <vp-text v-else>{{ formData.certificates[2].bfrq }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4">
                    <el-form-item prop="certificates[2].yxq" :rules="currentFormRule(formRules.certificates.yxq2)">
                    <template #label><vp-label zh="有效期" en="Valid Period"/></template>
                        <el-date-picker
                            v-if="isEditPage"
                            v-model="formData.certificates[2].yxq"
                            value-format="YYYY-MM-DD"
                            type="date"
                            class="w100"
                        />
                        <vp-text v-else>{{ formData.certificates[2].yxq }}</vp-text>
                    </el-form-item>
                </vp-col>
                <vp-col :span="4" v-if="isEditPage">
                    <el-form-item>
                        <template #label><vp-label zh="附件" en="Attachment" /></template>
                        <RowAttachment 
                            :attachmentList="formData.certificates[2].attachments" 
                            :readOnly="!isEditPage"
                            :show-attachment="false"
                            accept=".pdf"
                            @attachmentListEmit="formData.certificates[2].attachments = $event"
                        />
                    </el-form-item>
                </vp-col>
            </el-row>
            <el-row v-if="isEditPage">
                <vp-col :span="4">
                    <el-form-item>
                        <template #label><vp-label zh="应急设备清单" en="Emergency Equipment List" /></template>
                    </el-form-item>
                </vp-col>
                <vp-col :span="2"></vp-col>
                <vp-col :span="4">
                    <el-form-item>
                        <template #label><vp-label zh="附件" en="Attachment" /></template>
                        <RowAttachment 
                            :attachmentList="formData.yjsbqdAttachments" 
                            :readOnly="!isEditPage"
                            :show-attachment="false"
                            accept=".pdf"
                            @attachmentListEmit="formData.yjsbqdAttachments = $event"
                        />
                    </el-form-item>
                </vp-col>
            </el-row>
            <el-row v-if="isEditPage">
                <vp-col :span="4">
                    <el-form-item>
                        <template #label><vp-label zh="安全须知卡" en="Safety Notice Card" /></template>
                    </el-form-item>
                </vp-col>
                <vp-col :span="2"></vp-col>
                <vp-col :span="4">
                    <el-form-item>
                        <template #label><vp-label zh="附件" en="Attachment" /></template>
                        <RowAttachment 
                            :attachmentList="formData.aqxzkAttachments" 
                            :readOnly="!isEditPage"
                            :show-attachment="false"
                            accept=".pdf"
                            @attachmentListEmit="formData.aqxzkAttachments = $event"
                        />
                    </el-form-item>
                </vp-col>
            </el-row>
            <el-row v-if="isEditPage">
                <vp-col :span="4">
                    <el-form-item>
                        <template #label><vp-label zh="飞行手册改装清单" en="AFM Mod List" /></template>
                    </el-form-item>
                </vp-col>
                <vp-col :span="2"></vp-col>
                <vp-col :span="4">
                    <el-form-item>
                        <template #label><vp-label zh="附件" en="Attachment" /></template>
                        <RowAttachment 
                            :attachmentList="formData.fxscgzqdAttachments" 
                            :readOnly="!isEditPage"
                            :show-attachment="false"
                            @attachmentListEmit="formData.fxscgzqdAttachments = $event"
                        />
                    </el-form-item>
                </vp-col>
            </el-row>
            <el-row>
                <vp-col :span="1">
                    <el-form-item>
                        <template #label><vp-label zh="证书附件" en="Certificate Files" /></template>
                        <vp-table :data="certificateFiles" max-height="400">
                            <el-table-column type="index" align="center" label="#"></el-table-column>
                            <el-table-column width="150" show-overflow-tooltip>
                                <template #header><vp-label zh="文件类型" en="File Type"/></template>
                                <template #default="scope">
                                    <span>{{scope.row.type === 1 ? '国籍登记证号' : 
                                            scope.row.type === 2 ? '适航证号' : 
                                            scope.row.type === 3 ? '无线电台执照号' : 
                                            scope.row.type === 4 ? '应急设备清单' : 
                                            scope.row.type === 5 ? '安全须知卡' : 
                                            scope.row.type === 6 ? '飞行手册改装清单' : '' }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column>
                                <template #header><vp-label zh="文件名" en="File Name"/></template>
                                <template #default="scope">
                                    <el-link @click="viewFile(scope.row)">
                                        <span v-html="scope.row.wbwjm + (scope.row.hzm? '.' + scope.row.hzm : '')"></span>
                                    </el-link>
                                </template>
                            </el-table-column>
                            <el-table-column prop="wjdx" width="150">
                                <template #header><vp-label zh="文件大小" en="File Size"/></template>
                                <template #default="scope">
                                    {{scope.row.wjdx + " KB"}}
                                </template>
                            </el-table-column>
                            <el-table-column prop="czsj" width="160">
                                <template #header><vp-label zh="上传时间" en="Upload Time"/></template>
                            </el-table-column>
                            <el-table-column align="center" width="90" v-if="isEditPage">
                                <template #header><vp-label-operations/></template>
                                <template #default="scope">
                                    <el-button circle @click="handleDeleteCertificateFile(scope.row)"><SvgIcon name="ele-Minus"></SvgIcon></el-button>
                                </template>
                            </el-table-column>
                        </vp-table>
                    </el-form-item>
                </vp-col>
            </el-row>
        </vp-card>
        <vp-card>
            <template #header>
                <vp-label zh="飞机改装信息" en="Aircraft Modification Info" />
            </template>
            <el-row>
                <vp-col :span="1">
                    <el-form-item>
                        <template #label><vp-label zh="改装记录" en="Modification Record" /></template>
                        <vp-table :data="formData.modificationRecords" max-height="400">
                            <el-table-column type="index" align="center" label="#"></el-table-column>
                            <el-table-column width="200" show-overflow-tooltip>
                                <template #header><vp-label zh="改装号" en="STC/VSTC/Other NO"/></template>
                                <template #default="scope">
                                    <el-form-item :prop="`modificationRecords[${scope.$index}].gzh`" :rules="formRules.modificationRecords.gzh">
                                        <el-input v-model="scope.row.gzh" maxlength="100" v-if="isEditPage">
                                        </el-input>
                                        <span v-else>{{ scope.row.gzh }}</span>
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column width="160" show-overflow-tooltip>
                                <template #header><vp-label zh="改装日期" en="Date"/></template>
                                <template #default="scope">
                                    <el-form-item :prop="`modificationRecords[${scope.$index}].gzrq`" :rules="formRules.modificationRecords.gzrq">
                                        <el-date-picker
                                            v-model="scope.row.gzrq"
                                            v-if="isEditPage"
                                            value-format="YYYY-MM-DD"
                                            type="date"
                                            class="w100"
                                        />
                                        <span v-else>{{ scope.row.gzrq }}</span>
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column width="160" show-overflow-tooltip>
                                <template #header><vp-label zh="改装名称" en="Title"/></template>
                                <template #default="scope">
                                    <el-form-item :prop="`modificationRecords[${scope.$index}].gzmc`" :rules="formRules.modificationRecords.gzmc">
                                        <el-input v-model="scope.row.gzmc" maxlength="100" v-if="isEditPage" />
                                        <span v-else>{{ scope.row.gzmc }}</span>
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column min-width="160" show-overflow-tooltip>
                                <template #header><vp-label zh="内容" en="Note"/></template>
                                <template #default="scope">
                                    <el-input v-model="scope.row.nr" maxlength="1000" v-if="isEditPage" />
                                    <span v-else>{{ scope.row.nr }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column width="250" show-overflow-tooltip>
                                <template #header><vp-label zh="附件" en="Attachment"/></template>
                                <template #default="scope">
                                    <RowAttachment 
                                        :attachmentList="scope.row.attachments" 
                                        :readOnly="!isEditPage"
                                        @attachmentListEmit="scope.row.attachments = $event"
                                    />
                                </template>
                            </el-table-column>
                            <el-table-column align="center" width="60" v-if="isEditPage">
                                <template #header>
                                    <el-space>
                                        <el-button circle @click="handleAddModificationRecord()"><SvgIcon name="ele-Plus"></SvgIcon></el-button>
                                    </el-space>
                                </template>
                                <template #default="scope">
                                    <el-button circle @click="handleDeleteModificationRecord(scope.$index)"><SvgIcon name="ele-Minus"></SvgIcon></el-button>
                                </template>
                            </el-table-column>
                        </vp-table>
                    </el-form-item>
                </vp-col>
            </el-row>
        </vp-card>
        <vp-card>
            <template #header>
                <vp-label zh="飞机照片" en="Aircraft Photo" />
            </template>
            <VpFileListRow 
                :attachmentList="formData.fjzpAttachments" 
                :readOnly="!isEditPage"
                :show-attachment="false"
                @attachmentListEmit="formData.fjzpAttachments = $event"
            >
                <template #header><vp-label zh="照片附件" en="Photo List" /></template>
            </VpFileListRow>
        </vp-card>
        <vp-card>
            <template #header>
                <vp-label zh="附件" en="Attachment" />
            </template>
            <VpFileListRow 
                :attachmentList="formData.attachments" 
                :readOnly="!isEditPage"
                :show-attachment="false"
                @attachmentListEmit="formData.attachments = $event"
            >
                <template #header><vp-label zh="附件列表" en="File List" /></template>
            </VpFileListRow>
        </vp-card>
    </el-form>
</template>
<script setup lang="ts" name="aircraftForm">
import { ref, computed } from 'vue';
import validateUtils from '/@/utils/validateUtils';
import VpAircraftTypeSelect from '/@/components/vp/aircraftType/VpAircraftTypeSelect.vue';
import VpBaseSelectTree from '/@/components/vp/base/VpBaseSelectTree.vue';
import { verifiyNumberInteger, verifyNumberIntegerAndFloat3 } from '/@/utils/toolsValidate';
import VpDictSelect from '/@/components/vp/dict/VpDictSelect.vue';
import { ElMessage } from 'element-plus';
import VpFileListRow from '/@/components/vp/file/VpFileListRow.vue';
import RowAttachment from '/@/components/vp/file/VpRowAttachment.vue';
import commonFunction from '/@/utils/commonFunction';

const emits = defineEmits(['formSubmited']);
const props = defineProps({
    // 页面类型
	type: {
		type: String,
		default: 'add',
	},
	// 加载状态
	loading: {
		type: Boolean,
		default: false,
	},
});
const formData = ref({
    id:"",
    zt:10,
    jxid:"",
    jx:"",
    fjzch:"",
    fjxlh:"",
    bzm:"",
    gsbs:null,
    ssdwid:"",
    ssdwmc:"",
    jdid:"",
    jdmc:"",
    scrq:"",
    ccrq:"",
    sctryxrq:"",
    yxgf:"",
    smsm:"",
    xhh:"",
    dzxt:"",
    wxtxxt:"",
    adsbzt:"",
    adsbjsbz:"",
    ryxh:"",
    fdjhybh:"",
    zwsl:"",
    kz:"",
    zdqfzl:"",
    zdzlzl:"",
    zldw:"",
    yxrn:"",
    yxrndw:"",
    bz:"",
    softwareConfigs: [] as any[],
    certificates: [
        { lx: 10 },
        { lx: 20 },
        { lx: 30 },
    ] as any[],
    modificationRecords: [] as any[],
    yjsbqdAttachments: [] as any[],
    aqxzkAttachments: [] as any[],
    fxscgzqdAttachments: [] as any[],
    dzsbxxAttachments: [] as any[],
    dzsbrjgxqdAttachments: [] as any[],
    fjzpAttachments: [] as any[],
    attachments: [] as any[],
});
const formRules = {
    jxid:[ validateUtils.notNull ],
    fjzch:[ validateUtils.notNull, validateUtils.notChinese ],
    fjxlh:[ validateUtils.notNull, validateUtils.notChinese ],
    softwareConfigs: {
        mc:[ validateUtils.notNull ],
    },
    certificates: {
        zjh:[ validateUtils.notNull ],
        bfrq:[ validateUtils.notNull ],
        yxq0:[{
            validator: (rule: any, value: any, callback: any)=>{
                if(formData.value.certificates[0].bfrq && formData.value.certificates[0].yxq 
                    && formData.value.certificates[0].bfrq >= formData.value.certificates[0].yxq){
                    callback(new Error("有效期必须大于颁发日期"))
                }else{
                    callback()
                }
            },
        }],
        yxq1:[validateUtils.notNull,{
            validator: (rule: any, value: any, callback: any)=>{
                if(formData.value.certificates[1].bfrq && formData.value.certificates[1].yxq 
                    && formData.value.certificates[1].bfrq >= formData.value.certificates[1].yxq){
                    callback(new Error("有效期必须大于颁发日期"))
                }else{
                    callback()
                }
            },
        }],
        yxq2:[validateUtils.notNull,{
            validator: (rule: any, value: any, callback: any)=>{
                if(formData.value.certificates[2].bfrq && formData.value.certificates[2].yxq 
                    && formData.value.certificates[2].bfrq >= formData.value.certificates[2].yxq){
                    callback(new Error("有效期必须大于颁发日期"))
                }else{
                    callback()
                }
            },
        }],
    },
    modificationRecords: {
        gzh:[ validateUtils.notNull ],
        gzrq:[ validateUtils.notNull ],
        gzmc:[ validateUtils.notNull ],
    }
}

// 页面验证规则
const currentFormRules = computed(() => {
    if (isEditPage.value) {
        return formRules;
    }
    return {};
})
const currentFormRule = computed(() => {
    return (rule: any) => {
        if (isEditPage.value) {
            return rule;
        }
        return [];
    }
})

const formRef = ref();

// 是否是编辑页面
const isEditPage = computed(() => {
    return props.type === 'add' || props.type === 'edit';
});

// 清空数据
const initFormData = ()=>{
    formData.value = {
        id:"",
        zt:10,
        jxid:"",
        jx:"",
        fjzch:"",
        fjxlh:"",
        bzm:"",
        gsbs:null,
        ssdwid:"",
        ssdwmc:"",
        jdid:"",
        jdmc:"",
        scrq:"",
        ccrq:"",
        sctryxrq:"",
        yxgf:"",
        smsm:"",
        xhh:"",
        dzxt:"",
        wxtxxt:"",
        adsbzt:"",
        adsbjsbz:"",
        ryxh:"",
        fdjhybh:"",
        zwsl:"",
        kz:"",
        zdqfzl:"",
        zdzlzl:"",
        zldw:"",
        yxrn:"",
        yxrndw:"",
        bz:"",
        softwareConfigs: [] as any[],
        certificates: [
            { lx: 10 },
            { lx: 20 },
            { lx: 30 },
        ] as any[],
        modificationRecords: [] as any[],
        yjsbqdAttachments: [] as any[],
        aqxzkAttachments: [] as any[],
        fxscgzqdAttachments: [] as any[],
        dzsbxxAttachments: [] as any[],
        dzsbrjgxqdAttachments: [] as any[],
        fjzpAttachments: [] as any[],
        attachments: [] as any[],
    }
}

// 回显数据
const setData = (data: any) => {
    initFormData();
    formData.value = {
        ...formData.value,
        ...data,
    };
}

/**
 * 获取数据
 */
const getData = (): Promise<any>=>{
    return new Promise((resolve, reject) => {
        formRef.value.validate((valid: boolean) => {
            const data = {
                ...formData.value,
            };
            if (valid) {
                resolve(data);
            } else {
                reject();
            }
        })
    })
}

const { viewFile } = commonFunction();

// 选择客户
const handleChooseCustomer = () => {
    ElMessage.info("功能开发中");
}

// 新增系统软件
const handleAddSoftwareConfig = ()=>{
    formData.value.softwareConfigs.push({});
}

// 删除系统软件
const handleDeleteSoftwareConfig = (index: number)=>{
    formData.value.softwareConfigs.splice(index, 1);
}

// 证书附件
const certificateFiles = computed(() => {
    const t1 = formData.value.certificates[0].attachments || [];
    const t2 = formData.value.certificates[1].attachments || [];
    const t3 = formData.value.certificates[2].attachments || [];
    const t4 = formData.value.yjsbqdAttachments || [];
    const t5 = formData.value.aqxzkAttachments || [];
    const t6 = formData.value.fxscgzqdAttachments || [];
    t1.forEach((t: any) => { t.type = 1; });
    t2.forEach((t: any) => { t.type = 2; });
    t3.forEach((t: any) => { t.type = 3; });
    t4.forEach((t: any) => { t.type = 4; });
    t5.forEach((t: any) => { t.type = 5; });
    t6.forEach((t: any) => { t.type = 6; });
    return t1.concat(t2).concat(t3).concat(t4).concat(t5).concat(t6);
})

// 删除证书附件
const handleDeleteCertificateFile = (row: any) => {
    let attachments = [];
    if (row.type === 1) {
        attachments = formData.value.certificates[0].attachments;
    } else if (row.type === 2) {
        attachments = formData.value.certificates[1].attachments;
    } else if (row.type === 3) {
        attachments = formData.value.certificates[2].attachments;
    } else if (row.type === 4) {
        attachments = formData.value.yjsbqdAttachments;
    } else if (row.type === 5) {
        attachments = formData.value.aqxzkAttachments;
    } else if (row.type === 6) {
        attachments = formData.value.fxscgzqdAttachments;
    }
    let index = attachments.findIndex((attachment: any) => attachment === row);
    if (index !== -1) {
        attachments.splice(index, 1);
    }
}

// 新增改装记录
const handleAddModificationRecord = ()=>{
    formData.value.modificationRecords.push({});
}

// 删除改装记录
const handleDeleteModificationRecord = (index: number)=>{
    formData.value.modificationRecords.splice(index, 1);
}

defineExpose({
    setData,
    getData,
})

</script>
<style scoped lang="scss">
</style>